Given 'courses database is populated' do
  @valid_attributes = {
    :start_date => Time.now,
    :end_date => Time.now,
    :name => "value for name"
  }

  @fall2009 = Term.create!({
    :start_date => Date.parse("August 26, 2009"),
    :end_date => Date.parse("December 11, 2009"),
    :name => "Fall 2009",
  })

  @cs61a = Course.create!({
    :department => "CS",
    :course_number => "61A",
    :term => @fall2009,
    :description => "The Structure and Interpretation of Computer Progra...",
    :units => 4
  })

  @cs61a_lec = Lecture.create!({
    :event_name=>"CS61a lecture",
    :event_type=>"LEC",
    :location=>"1 PIMENTEL",
    :start_time=>Time.mktime(2000,1,1,10,0),
    :stop_time=>Time.mktime(2000,1,1,12,0),
    :monday=>true,
    :tuesday=>false,
    :wednesday=>true,
    :thursday=>false,
    :friday=>true,
    :saturday=>false,
    :sunday=>false,
    :finals_group=>15,
    :ccn=>26266,
    :section_number=>"001",
    :course=>@cs61a
  })
  
  @cs61a_dis = Discussion.create!({
    :event_name=>"CS61a discussion",
    :event_type=>"DIS",
    :location=>"6 EVANS",
    :start_time=>Time.mktime(2000,1,1,10,00),
    :stop_time=>Time.mktime(2000,1,1,11,00),
    :monday=>false,
    :tuesday=>false,
    :wednesday=>false,
    :thursday=>true,
    :friday=>false,
    :saturday=>false,
    :sunday=>false,
    :ccn=>263412,
    :section_number=>"011",
    :course=>@cs61a,
  })

  @cs61b = Course.create!({
    :department => "CS",
    :course_number => "61B",
    :term => @fall2009,
    :description => "Data Structures and Programming Methodology",
    :units => 4
  })

  @cs61b_lec = Lecture.create!({
    :event_name=>"CS61B lecture",
    :event_type=>"LEC",
    :location=>"2050 VALLEY LSB",
    :start_time=>Time.mktime(2000,1,1,13,00),
    :stop_time=>Time.mktime(2000,1,1,14,00),
    :monday=>false,
    :tuesday=>true,# modified for testing
    :wednesday=>false,
    :thursday=>true,# modified for testing
    :friday=>false,
    :saturday=>false,
    :sunday=>false,
    :finals_group=>12,
    :ccn=>26341,
    :section_number=>"001",
    :course=>@cs61b,
  })

  @cs61b_dis = Discussion.create!({
    :event_name=>"CS61b discussion",
    :event_type=>"DIS",
    :location=>"6 EVANS",
    :start_time=>Time.mktime(2000,1,1,10,00),
    :stop_time=>Time.mktime(2000,1,1,11,00),
    :monday=>false,
    :tuesday=>false,
    :wednesday=>false,
    :thursday=>true,
    :friday=>false,
    :saturday=>false,
    :sunday=>false,
    :ccn=>26347,
    :section_number=>"011",
    :course=>@cs61b,
  })
  @cs61a_lec.course.id.should == @cs61a.id
end

And "there are ratings for the first lecture in the database" do
  @valid_instructor_attributes = {
    :first_name => "Armando",
    :last_name => "Fox",
    :url => "http://hkn.eecs.berkeley.edu/student/CourseSurvey/instructors/CS/Professor/Fox,Armando/"
  }
  armando = Instructor.create!(@valid_instructor_attributes)
  armando.lectures << Lecture.find(:first)
  armando.teachings[0].effectiveness = 7
  armando.teachings[0].usefulness = 6.9
  armando.teachings[0].save!
  Lecture.find(:first).teachings[0].usefulness.should == 6.9
end